package com.example.farmeri.ui.news;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.RecyclerView;

import com.example.farmeri.R;
import com.example.farmeri.pojo.Message;
import com.example.farmeri.pojo.Messages;
import com.example.farmeri.tools.DataUtils;

import java.util.ArrayList;

public abstract class BaseAdapter extends RecyclerView.Adapter {


    protected View.OnTouchListener getHorizonSlideListener(LinearLayout layoutHide,HorizontalScrollView container) {
        return new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                //用户行为
                int action = event.getActionMasked();
                switch(action){
                    case MotionEvent.ACTION_UP:
                        //操作界面的宽度
                        int hideLayoutWidth = layoutHide.getWidth();
                        //滑动的距离
                        int scrollX = container.getScrollX();
                        //滑动距离大于操作界面的一半时显示操作界面
                        if (scrollX > hideLayoutWidth/2){
                            container.smoothScrollTo(hideLayoutWidth,0);
                        }else {
                            container.smoothScrollTo(0,0);
                        }
                        return true;
                }
                return false;
            }
        };
    }


//    protected CompoundButton.OnCheckedChangeListener getCheckedChangeListener(){
//        return new CompoundButton.OnCheckedChangeListener() {
//            @Override
//            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
//                //获取当前的item位置
//                int position = holder.getAdapterPosition();
//                if (isChecked){
//                    onExtraClickListenerNews.onChecked(position);
//                }else {
//                    onExtraClickListenerNews.onUnChecked(position);
//                }
//
//            }
//        }
//    }
}

